<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <title>收容社区</title>

    <link    href="/css/bootstrap.css" rel="stylesheet">
    <link href="/css/bootstrap-theme.css" rel="stylesheet">
    <link href="/css/pet.css" rel="stylesheet">
    <script src="/js/jquery-3.4.1.min.js"></script>
    <script src="/js/bootstrap.js" type="application/javascript"></script>
    <script type="text/javascript">
<!--        后端传来的值进行转义-->
        $(function(){
            var content = $("#questionTitle").val();
            $(".showHtml").html(content);
        });
    </script>



</head>
<body background="/img/background.jpg" style="background-size: cover">
<!--导入模板 -->

<div th:insert="~{navgation :: copy}"></div>

<div class="container-fluid main">
    <div class="row">
        <div class="col-lg-9 col-md-12 col-sm-12 col-xs-12" th:if="${Search == null}">
            <h2><span class="glyphicon glyphicon-list" aria-hidden="true"></span> 发现</h2>
            <hr>

            <div class="media" th:each="question : ${pagination.data}">
                <div class="media-left">
                    <a href="#">
                        <img class="media-object img-rounded"
                             th:src="${question.user.avatarUrl}">
                    </a>
                </div>
                <div class="media-body">
                    <h4 class="media-heading">
                        <a th:href="@{'/question/'+ ${question.id}}" th:text="${question.title}"></a>
                    </h4>
                    <br>
                    <span class="text-desc"><span th:text="${question.commentCount}"></span> 个回复 • <span
                            th:text="${question.viewCount}"></span> 次浏览 • <span
                            th:text="${#dates.format(question.gmtCreate,'yyyy-MM-dd HH:mm')}"></span></span>
                </div>
            </div>
            <nav aria-label="Page navigation">
                <ul class="pagination">
                    <li th:if="${pagination.showFirstPage}">
                        <a href="/?page=1" aria-label="Previous">
                            <span aria-hidden="true">&lt;&lt;</span>
                        </a>
                    </li>
                    <li th:if="${pagination.showPrevious}">
                        <a th:href="@{/index(page=${pagination.page - 1})}" aria-label="Previous">
                            <span aria-hidden="true">&lt;</span>
                        </a>
                    </li>

                    <li th:each="page : ${pagination.pages}" th:class="${pagination.page == page}? 'active' : ''">
                        <a th:href="@{/index(page=${page})}" th:text="${page}"></a>
                    </li>

                    <li th:if="${pagination.showNext}">
                        <a th:href="@{/index(page=${pagination.page + 1 })}" aria-label="Previous">
                            <span aria-hidden="true">&gt;</span>
                        </a>
                    </li>
                    <li th:if="${pagination.showEndPage}">
                        <a th:href="@{/index(page=${pagination.totalpage})}" aria-label="Previous">
                            <span aria-hidden="true">&gt;&gt;</span>
                        </a>
                    </li>
                </ul>
            </nav>
        </div>

<!--查询结果-->
        <div class="col-lg-9 col-md-12 col-sm-12 col-xs-12" th:if="${Search}">
            <h2><span class="glyphicon glyphicon-search" aria-hidden="true"></span> 结果</h2>
            <hr>
            <p th:if="${alert != null}" th:text="${alert}"  style="color: #e7e7e7; font-size: 25px;margin-left: 12px;font-family: YouYuan;">
            <div class="media" th:each="question : ${Search.data}" style="margin-bottom: 15px;">
                <div class="media-left">
                    <a href="#">
                        <img class="media-object img-rounded"
                             th:src="${question.userAvatarUrl}">
                    </a>
                </div>
                <div class="media-body">
                    <h4 class="media-heading">
                        <a th:href="@{'/question/'+ ${question.questionId}}">
                            <span class="showHtml">
                                <input id="questionTitle" type="hidden" th:value="${question.questionTitle}">
                            </span>
                        </a>
                    </h4>
                    <br>
                    <span class="text-desc"><span th:text="${question.questionCommentCount}"></span> 个回复 • <span
                            th:text="${question.questionViewCount}"></span> 次浏览 • <span
                            th:text="${#dates.format(question.questionGmtCreate,'yyyy-MM-dd HH:mm')}"></span></span>
                </div>
            </div>

                <nav aria-label="Page navigation">
                    <ul class="pagination">
                        <li th:if="${Search.showFirstPage}">
                            <a href="/?page=1" aria-label="Previous">
                                <span aria-hidden="true">&lt;&lt;</span>
                            </a>
                        </li>
                        <li th:if="${Search.showPrevious}">
                            <a th:href="@{/searchkey(page=${Search.page - 1})}" aria-label="Previous">
                                <span aria-hidden="true">&lt;</span>
                            </a>
                        </li>

                        <li th:each="page : ${Search.pages}" th:class="${Search.page == page}? 'active' : ''">
                            <a th:href="@{/searchkey(page=${page})}" th:text="${page}"></a>
                        </li>

                        <li th:if="${Search.showNext}">
                            <a th:href="@{/searchkey(page=${Search.page + 1 })}" aria-label="Previous">
                                <span aria-hidden="true">&gt;</span>
                            </a>
                        </li>
                        <li th:if="${Search.showEndPage}">
                            <a th:href="@{/searchkey(page=${Search.totalpage})}" aria-label="Previous">
                                <span aria-hidden="true">&gt;&gt;</span>
                            </a>
                        </li>
                    </ul>
                </nav>
        </div>

        <div class="col-lg-3 col-md-12 col-sm-12 col-xs-12" >
            <h3>温馨提醒</h3>
            <span style="line-height: 37px"> • 保护好自己的隐私</span></br>
            <span style="line-height: 37px"> • 诚信可贵，欺人可耻</span></br>
            <span style="line-height: 37px"> • 防人之心不可无</span></br>
            <span style="line-height: 37px"> • 一切损失，本站不负责</span></br>
            <hr>
            <h4>热门标签</h4>
            <ul class="question-related">
                <li th:each="tag : ${tags}"  style="line-height: 25px;">
                    <a th:href="@{'/searchkey?search='+ ${tag}}" th:text="${tag}"></a>
                </li>
            </ul>
        </div>
    </div>
</div>

</body>
</html>